package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dao.SetmealPageDTO;
import com.sky.entity.Setmeal;
import com.sky.enumeration.OperationType;
import com.sky.vo.SetmealPageVO;
import com.sky.vo.SetmealVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealMapper {
    @Select("select count(*) from setmeal where category_id = #{id} and status = 1")
    Integer count(Integer id);


    @AutoFill(value = OperationType.INSERT)
    void save(Setmeal setmeal);

    Page<SetmealPageVO> page(SetmealPageDTO setmealPageDTO);


    @Select("select * from setmeal where id = #{id}")
    Setmeal getById(Long id);

    @AutoFill(value = OperationType.UPDATE)
    void update(Setmeal setmeal);

    @Delete("delete from setmeal where id = #{id}")
    void delete(Long id);


    List<Setmeal> list(Long categoryId);

    @Select("select * from setmeal where status = #{status}")
    Integer countSetmeal(Integer status);
}
